﻿/******************************************************************************************
*                                                                                         *    
*                              Developed by Bruno Pires                                   *
*                                                                                         *
*                             email: bruno@blastersystems.com                             *
*                               web: www.blastersystems.com                               *
*                              blog: www.blastersystems.com/blog                          *
*                           twitter: brunoacpires                                         *
*                                                                                         *
*                      Software available under GNU LGPL v3 License                       *
*                                                                                         *    
* *****************************************************************************************/  

function getBingMaps(mapContainer, latitude, longitude, zoomRange, pushPin, pushPinTitle, pushPinDescription, mapStyle, mapMode, mapUnit, mapWidth, mapHeight) {

    /*set the map size*/
    document.getElementById('myMap').setAttribute('style', 'position:relative; width:' + mapWidth + '; height:' + mapHeight + ';');
    /**/

    var map = null;
    var selStyle = null;
    var viewMode = null;
    var distUnit = null;

    switch (mapStyle) {
        case 'Road':
            selStyle = VEMapStyle.Road;
            break;
        case 'Shaded':
            selStyle = VEMapStyle.Shaded;
            break;
        case 'Aerial':
            selStyle = VEMapStyle.Aerial;
            break;
        case 'Hybrid':
            selStyle = VEMapStyle.Hybrid;
            break;
        case 'Oblique':
            selStyle = VEMapStyle.Oblique;
            break;
        case 'Birdseye':
            selStyle = VEMapStyle.Birdseye;
            break;
        case 'BirdseyeHybrid':
            selStyle = VEMapStyle.BirdseyeHybrid;
            break;
    }

    switch (mapMode) {
        case 'Mode2D':
            viewMode = VEMapMode.Mode2D;
            break;
        case 'Mode3D':
            viewMode = VEMapMode.Mode3D;
            break;
    }


    switch (mapUnit) {
        case 'Kilometers':
            distUnit = VEDistanceUnit.Kilometers;
            break;
        case 'Miles':
            distUnit = VEDistanceUnit.Miles;
            break;
    }

    var zoom = zoomRange;
    var localization = new VELatLong(latitude, longitude);

    map = new VEMap(''+mapContainer+'');
    map.LoadMap(localization, zoom, selStyle, false, viewMode, true, 1);
    map.SetScaleBarDistanceUnit(distUnit);

    if (pushPin) {
        var shape = new VEShape(VEShapeType.Pushpin, localization);
        shape.SetTitle('' + pushPinTitle + '');
        shape.SetDescription('' + pushPinDescription + '');
        map.AddShape(shape);
    }
}

